require Pod::Executable.execute_command('node', ['-p',
  'require.resolve(
    "react-native/scripts/react_native_pods.rb",
    {paths: [process.argv[1]]},
  )', __dir__]).strip

platform :ios, min_ios_version_supported
prepare_react_native_project!

linkage = ENV['USE_FRAMEWORKS']
if linkage != nil
  Pod::UI.puts "Configuring Pod with #{linkage}ally linked Frameworks".green
  use_frameworks! :linkage => linkage.to_sym
end


def all_pods
  config = use_native_modules!

  flags = get_default_flags()

  use_react_native!(
    :path => "../node_modules/react-native",
    :hermes_enabled => flags[:hermes_enabled],
    :fabric_enabled => flags[:fabric_enabled],
    # An absolute path to your application root.
    :app_path => "#{Pod::Config.instance.installation_root}/.."
  )

  pod 'HMSegmentedControl'
end

post_install do |installer|
   config = use_native_modules!
   react_native_post_install(
        installer,
        config[:reactNativePath],
        :mac_catalyst_enabled => false,
        # :ccache_enabled => true
      )

  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['HEADER_SEARCH_PATHS'] ||= ['$(inherited)']
      config.build_settings['HEADER_SEARCH_PATHS'] << '$(PODS_ROOT)/Headers/Public/React-hermes'
    end
  end

  installer.pods_project.build_configurations.each do |config|
    config.build_settings['USE_HERMES'] = '1'  # Ensure Hermes is enabled
  end
end

target 'playground' do
  all_pods
end

target 'NavigationTests' do
  all_pods
  pod 'OCMock'
end

target 'NavigationIOS12Tests' do
  all_pods
  pod 'OCMock'
end

target 'SnapshotTests' do
  all_pods
  pod 'OCMock'
end
